package com.meshnetics.gb.stack.core.apl.type;

import com.meshnetics.gb.type.impl.additional.NumberUByte;
import com.meshnetics.gb.type.impl.additional.TypeInstantiable;
import com.meshnetics.gb.util.formatters.NumberFormatter;

import java.nio.ByteBuffer;

/**
 * Length (of clusters array, of simple descriptor etc).
 *
 * @author Yury Aserchev (yaserchev@meshnetics.com)
 *         Date: 01.10.2008 13:01:28
 */
public final class Length extends NumberUByte {
    private static final TypeInstantiable TYPE = new TypeInstantiable("length", Length.class);
    private static final NumberFormatter FORMATTER = new NumberFormatter() {
        public String formatNumber(final long value) {
            return "length: " + NumberUByte.FORMATTER_UBYTE.formatNumber(value);
        }
    };

    public Length(final long value) {
        super(TYPE, value);
    }

    public Length(final ByteBuffer buffer) {
        super(TYPE, buffer);
    }

    protected NumberFormatter getFormatter() {
        return FORMATTER;
    }
}
